package com.itheima.static_case.Demo4;

public class Demo4 {
    public static void main(String[] args) {
        // 案例4 - static应用：单例设计模式(饿汉、懒汉)

        // 懒汉模式
        Student2 student2 = Student2.getInstance();
        System.out.println(student2.getName());

        student2.setName("懒汉----1");
        System.out.println(student2.getName());


        System.out.println("-------------");

        // 饿汉模式
        Student1 student1 = Student1.getInstance();

        System.out.println(student1.getName());

        student1.setName("饿汉---1");

        System.out.println(student1.getName());
    }
}
